package com.itcast.Service.impl;

import com.itcast.Dao.Dao;
import com.itcast.Service.BookService;
import com.itcast.domain.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookServiceImpl implements BookService {
    //自动装配: 从IOC容器(父容器)中获取bean
    @Autowired
    private Dao.BookDao bookDao;

    //返回值: 执行成功与否的结果, true表示成功,待会扩展
    public boolean save(Book book) {
        bookDao.save(book);
        return true;
    }

    public boolean update(Book book) {
        bookDao.update(book);
        return true;
    }

    public boolean delete(Integer id) {
        bookDao.delete(id);
        return true;
    }

    public Book getById(Integer id) {
        return bookDao.getById(id);
    }

    public List<Book> getAll() {
        return bookDao.getAll();
    }
}